package m3f.matrix;

import java.util.Enumeration;

import org.jblas.DoubleMatrix;

public class Minibatch{
	private DoubleMatrix batch;
	private int id;
	
	public Minibatch(int rows, int cols){
		batch = DoubleMatrix.zeros(rows, cols);
	}
	
	public Minibatch(int rows, int cols, int id){
		batch = DoubleMatrix.zeros(rows, cols);
		this.id = id;
	}
	
	public DoubleMatrix matrix(){
		return batch;
	}
	
	public void setColumn(int j, SparseVector v){
		Enumeration<Integer> idx = v.getNonZeros();
		try{
		while(idx.hasMoreElements()){
			int i = idx.nextElement();
			batch.put(i, j, v.get(i));
		}
		}catch(Exception e){
			System.err.println(v.toString());
			e.printStackTrace();
			throw new RuntimeException();
		}
	}
	
	public int getId(){
		return id;
	}
}